package com.ls.demo.tcp.config;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author liShan
 * @date 2019/8/28 15:50
 */
@Configuration
@ConfigurationProperties(prefix = "netty.tcp.server")
@Getter
@Setter
@ToString
public class TcpServerProperties {

    private String host = "127.0.0.1";
    private Integer port = 8082;
    /**
     * 处理Accept连接事件的线程，这里线程数设置为1即可，netty处理链接事件默认为单线程，过度设置反而浪费cpu资源
     */
    private int bossNioEventLoopGroupSize = 1;
    private int workNioEventLoopGroupSize ;

    {
        workNioEventLoopGroupSize = Runtime.getRuntime().availableProcessors()*2;
    }

    /**
     * 是否保持长链接
     */
    private Boolean tcpKeepAlive = true;

    /**
     * 心跳检查时间间隔，单位毫秒
     */
    private long allIdleTime = 10000;
    private long readerIdleTime = 10000;
    private long writerIdleTime = 10000;


}
